package com.tanhua.model.vo;

import com.tanhua.model.domain.Announcement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.text.SimpleDateFormat;

/**
 * @author げっしょく
 * @date 2021/10/30
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class NoticeVo {
    private String id;
    private String title;
    private String description;
    private String createDate;

    public static NoticeVo init(Announcement notice) {
        NoticeVo noticeVo = new NoticeVo();
        BeanUtils.copyProperties(notice, noticeVo);
        noticeVo.setId(notice.toString());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年M月d日 HH:mm:ss");
        String format = simpleDateFormat.format(notice.getCreated());
        noticeVo.setCreateDate(format);
        return noticeVo;
    }
}
